
//*****************************************
// Ptorocol
//*****************************************

 enum
 {
 	AS_SERVICE_START = 100,
 	AS_PROGRAM_LIST,
 	AS_SERVICE_END,
 	AS_ICON_IMAGE
 };
 
 enum
 {
 	REQUEST_PROGRAM_LIST = 100,
 	REQUEST_PROGRAM_ICON = 101
 };


#define MAX_PACKET_SIZE			256
#define MAX_ICON_SIZE			2048
#define MAX_ICON_PACKET_SIZE	4096


 class CConnectSocket
 {
 private:
 	WSADATA m_WsaData;
 	SOCKET m_Socket;
 	SOCKADDR_IN m_ServAddr;
	HANDLE	m_hThread;
	DWORD	m_ThreadId;
 
 public:
 	CConnectSocket();
	~CConnectSocket();

	void RequestServiceEnd();
	void RequestServiceStart();

 private:
	 void ProcessPacket(char* message, short protocol_type);
	 void OnRequestProgramList(char* message);
	 void OnRequestProgramIcon(char* message);



	 friend UINT WINAPI SocketThreadProc(void* pParam);
 };
 

static int readn(SOCKET socket, char* message, int n);
static UINT WINAPI SocketThreadProc( void* pParam );



